home *** CD-ROM | disk | FTP | other *** search
/ Ham Radio 2000 #1 / Ham Radio 2000.iso / ham2000 / packet / p_aa4re / bb212src / bbfsd.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  1991-11-30  |  3.6 KB  |  123 lines

  1. (*===========================================================================*)
  2. (* File subsystem -- Download file                                           *)
  3. (*                                                                           *)
  4. (*   Copyright 1988, 1989, 1990, 1991 by H. Roy Engehausen.  All rights      *)
  5. (*   reserved.                                                               *)
  6. (*                                                                           *)
  7. (*===========================================================================*)
  8.  
  9. {$O+}
  10.  
  11. UNIT BBFSD;
  12.  
  13. INTERFACE
  14.  
  15. PROCEDURE down_file_cmd(cmd_string : STRING);
  16.  
  17. IMPLEMENTATION
  18.  
  19. USES
  20.   DOS,
  21.   bbdummy,
  22.   bbfsm,
  23.   bbfssf,
  24.   bblog,
  25.   bbmdata,
  26.   bbmess,
  27.   bbmisc2,
  28.   bbsdata,
  29.   bbstr,
  30.   bbtask,
  31.   bbtime,
  32.   bbwin,
  33.   match;
  34.  
  35. PROCEDURE down_file_cmd(cmd_string : STRING);
  36.  
  37.   VAR
  38.     dir_to_search : fsb_name_str;
  39.     i             : WORD;
  40.     look          : SEARCHREC;
  41.     search_arg    : file_name_str;
  42.     this_fsb      : fsb_ptr;
  43.     word_count    : BYTE;
  44.  
  45.   {$I BBFSI.PAS}
  46.  
  47.   BEGIN;
  48.  
  49.     (*-----------------------------------------------------------------------*)
  50.     (* Parse command and execute right routine                               *)
  51.     (*-----------------------------------------------------------------------*)
  52.  
  53.     IF cmd_string[2] <> ' ' THEN
  54.       BEGIN;
  55.         send_message(message_err_2nd);
  56.         active_tcb^.error_sw := TRUE;
  57.         EXIT;
  58.       END;
  59.  
  60.     upcase_str_var(cmd_string);
  61.  
  62.     word_count := words(cmd_string);
  63.  
  64.     IF word_count < 3 THEN
  65.       BEGIN;
  66.         send_message(message_not_en);
  67.         active_tcb^.error_sw := TRUE;
  68.         EXIT;
  69.       END;
  70.  
  71.     IF word_count > 3 THEN
  72.       BEGIN;
  73.         send_message(message_err_wrd);
  74.         active_tcb^.error_sw := TRUE;
  75.         EXIT;
  76.       END;
  77.  
  78.     (*-----------------------------------------------------------------------*)
  79.     (* Parse                                                                 *)
  80.     (*-----------------------------------------------------------------------*)
  81.  
  82.     dir_to_search := subwordl(cmd_string, 2, SIZEOF(fsb_name_str) - 1);
  83.  
  84.     search_arg    := subwordl(cmd_string, 3, SIZEOF(search_arg)   - 1);
  85.  
  86.     (*-----------------------------------------------------------------------*)
  87.     (* Find the directory                                                    *)
  88.     (*-----------------------------------------------------------------------*)
  89.  
  90.     this_fsb := find_fsb(dir_to_search);
  91.  
  92.     IF (this_fsb = NIL) OR
  93.                    (active_tcb^.uid_data.user_class < this_fsb^.fsb_down) THEN
  94.       BEGIN;
  95.         send_message(message_no_files_one);
  96.         active_tcb^.error_sw := TRUE;
  97.         EXIT;
  98.       END;
  99.  
  100.     (*-----------------------------------------------------------------------*)
  101.     (* Check for subdirectory                                                *)
  102.     (*-----------------------------------------------------------------------*)
  103.  
  104.     IF (POS('\', search_arg) > 0) AND NOT this_fsb^.fsb_f_subdir_ok THEN
  105.       BEGIN;
  106.         send_message(message_no_slash);
  107.         active_tcb^.error_sw := TRUE;
  108.         EXIT;
  109.       END;
  110.  
  111.     log_data_s(cmd_string);
  112.  
  113.     (*-----------------------------------------------------------------------*)
  114.     (* Send the file                                                         *)
  115.     (*-----------------------------------------------------------------------*)
  116.  
  117.     send_file(this_fsb^.fsb_path + search_arg,
  118.        (active_tcb^.tcb_type = th_operator) AND (active_tcb^.conv_tcb <> NIL));
  119.  
  120.   END;
  121.  
  122. END.
  123.